package org.flower.web.servlet;

import org.flower.bean.Collect;
import org.flower.entity.User;
import org.flower.service.CollectSrevice;
import org.flower.service.impl.CollectServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/collectServlet")
public class collectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CollectSrevice coll = new CollectServiceImpl();
        User user= (User)request.getSession().getAttribute("user");
        List<Collect> list = coll.getAll(user.getId());
        request.getSession().setAttribute("coll",list);
        response.sendRedirect("collect.jsp");
    }
}
